function reverseArray<Type>(arr: Type[]): Type[] {
  return arr.reverse()
}

const numberArr = reverseArray([1, 2, 3, 4, 5])
const stringArr = reverseArray(['1', '2', '3', '4', '5'])
console.log(numberArr)
console.log(stringArr)

interface IResponse<T> {
  data: T;
  code: number;
}

const res: IResponse<string> = { data: 'hello', code: 200 }
const res2: IResponse<{name: string, age: number}> = {
  data: { name: 'shawlee', age: 18 },
  code: 200
}

class Box<T> {
  constructor(public _value: T) {}
  get value(): T {
    return this._value
  }

  set value(value: T) {
    this._value = value
  }
}

function formatUser<T extends { [key: string]: unknown }>(user: T): string {
  return Object.entries(user)
    .map(([key, value]) => `${key}: ${value}`)
    .join(', ')
}

console.log(formatUser({ name: 'shawlee', age: 18, length: 1 }))
console.log(formatUser({ level: 2, msg: 'warn', length: 2 }))

export {}